package com.zhu2chu.log4j2monitor.shared.interceptor;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.jfinal.aop.Interceptor;
import com.jfinal.aop.Invocation;
import com.zhu2chu.log4j2monitor.webpage.LogMonitorController;

/**
 * 2018年1月14日 21:07:13
 * 系统全局异常拦截器
 * 
 * @author ThreeX
 * @link http://www.zhu2chu.com
 *
 */
public class ExceptionInterceptor implements Interceptor {

    private static final Logger log = LogManager.getLogger(LogMonitorController.class);

    @Override
    public void intercept(Invocation inv) {
        try {
            inv.invoke();
        } catch (Exception e) {
            if (log.isErrorEnabled()) {
                log.error(e, e.fillInStackTrace());
            }
        }
    }

}
